package cn.iocoder.yudao.module.xhyy.controller.app.carousel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.xhyy.controller.app.carousel.vo.AppCarouselPageReqVO;
import cn.iocoder.yudao.module.xhyy.controller.app.carousel.vo.AppCarouselRespVO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.carousel.CarouselDO;
import cn.iocoder.yudao.module.xhyy.service.carousel.CarouselService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 轮播图")
@RestController
@RequestMapping("/xhyy/carousel")
@Validated
public class AppCarouselController {

    @Resource
    private CarouselService carouselService;







    @GetMapping("/get")
    @Operation(summary = "获得轮播图")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppCarouselRespVO> getCarousel(@RequestParam("id") Integer id) {
        CarouselDO carousel = carouselService.getCarousel(id);
        return success(BeanUtils.toBean(carousel, AppCarouselRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得轮播图分页")
    public CommonResult<PageResult<AppCarouselRespVO>> getCarouselPage(@Valid AppCarouselPageReqVO pageReqVO) {
        PageResult<CarouselDO> pageResult = carouselService.getCarouselPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppCarouselRespVO.class));
    }




}